package net.stamfest.rrd.tests;

import java.util.HashMap;
import java.util.Map.Entry;

import net.stamfest.rrd.CommandResult;
import net.stamfest.rrd.RRDCommandPool;
import net.stamfest.rrd.TCPRRDCommandFactory;

/**
 * 
 * <p>
 * Description: 通过rrd server可以实现远程访问的功能，正在尝试部署
 * </p>
 * @since 
 * @see 
 */
public class HelloPool {
    public static void main(String[] args) throws Exception {
        //        String rrdFileName = args[2];
        //        RRDCommandPool pool = new RRDCommandPool(10, new TCPRRDCommandFactory(Integer.parseInt(args[0]), args[1]));
        String rrdFileName = "C:\\cacti\\test.rrd";
        RRDCommandPool pool = new RRDCommandPool(10, new TCPRRDCommandFactory(80, "localhost"));

        for (int i = 0; i < 60; i++) {
            System.out.println("start " + i);
            CommandResult result = pool.command(new String[] { "info", rrdFileName });
            System.out.println(result);

            HashMap<String, String> hm = result.getInfo();

            if (hm != null) {
                for (Entry<String, String> e : hm.entrySet()) {
                    System.out.printf("%s:\t%s\n", e.getKey(), e.getValue());
                }
            }
            System.out.println("done " + i);

            Thread.sleep(10000);
        }
    }
}
